import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

//服务器类
public class Server {
    public Server() {
        try {
            ServerSocket serverSocket = new ServerSocket(8099);

            while (true){
                Socket socket = serverSocket.accept();
                InputStream is = socket.getInputStream();
                OutputStream os = socket.getOutputStream();

                byte [] by = new byte[1024];
                is.read(by);
                String  str = new String(by);
                System.out.println("客户端发送:"+str.trim());

                os.write("欢迎光临".getBytes());
                os.flush();

                os.close();
                is.close();
                socket.close();

            }



        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new Server();
    }
}
